Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Bias and clarify use of TRNG #6

Merged
merged 4 commits into from
Jul 26, 2023
Merged

Conversation

henrygab
Copy link
Contributor

Fixes #2

Tested and works.

  1. Remove existing bias towards characters earlier in the allowed alphabet. This is done by dynamically determining the maximum integral multiple value in a char, and excluding TRNG data that is outside the range.

  2. Avoids calls to rand() because that is (normally) not cryptographically random.

  3. No new memory allocations are used.

  4. Every call to furi_hal_random_get() takes a semaphore and re-initializes the TRNG hardware. This is inefficient and slower than using furi_hal_random_fill_buf().

  5. Iteratively call furi_hal_random_fill_buf() until the required password length is filled with valid (unbiased) characters.

  6. Overwrite password buffer when free'ing state. Again ... just good security hygiene.

  7. CI enabled -- automatic build via official ufbt GitHub Action ... FAP is built by GitHub!

@anakod anakod merged commit 6324f81 into anakod:main Jul 26, 2023
@henrygab henrygab deleted the rand_clarity branch July 26, 2023 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rand() is NOT cryptographically safe ... even if flipper zero implementation happens to be
2 participants